use core::{
     panic::PanicInfo, str
};
use mlibs::periph::flash;
use thiserror_no_std::Error;
pub type FlashErr = flash::Error;

#[panic_handler]
fn panic_handler(_info: &PanicInfo) -> ! {
    loop {}
}

#[derive(Error)]
pub enum AppErr {
    #[error("flash:{0}")]
    Flash(#[from] FlashErr),

    #[error("other:{0}")]
    Other(&'static str),
}

impl AppErr {

    pub fn other_msg(&self) -> &'static str {
        match self {
            AppErr::Flash(_) => "",
            AppErr::Other(msg) => msg, 
        }
    }
}

// struct VecFmt {
//     vec: Vec<u8>,
// }

// impl VecFmt {

//     pub fn new() -> Self {
//         Self { vec: Vec::new() }
//     }

//     pub fn as_str(&self) -> &str {
//         unsafe { str::from_utf8_unchecked(&self.vec) }
//     }
// }

// impl Write for VecFmt {

//     fn write_str(&mut self, s: &str) -> core::fmt::Result {
//         self.vec.extend_from_slice(s.as_bytes());
//         Ok(())
//     }
// }


